package org.lds.message.center.client;

import org.lds.message.center.client.properties.MessageCenterClientProperties;
import org.lds.message.center.common.Endpoint;
import org.lds.message.center.common.constant.EndpointConstant;
import org.lds.message.center.common.model.ResultDTO;
import org.lds.message.center.common.model.request.PublicRequest;
import org.lds.message.center.common.util.RestUtil;
import org.springframework.core.ParameterizedTypeReference;

public class HttpClient implements Endpoint {

    private final String URL_PREFIX;

    public HttpClient(MessageCenterClientProperties clientProperties) {
        this.URL_PREFIX = clientProperties.getEndpoint() + EndpointConstant.V1;
    }

    @Override
    public ResultDTO common(PublicRequest request) {
        return RestUtil.post(URL_PREFIX + EndpointConstant.PUBLIC, request,
                new ParameterizedTypeReference<ResultDTO>() {});
    }

}
